from django import forms
from logdjango.models import Entry

import logging

class EntryForm(forms.ModelForm):
    
    class Meta:
        model = Entry
        #fields = ('name',)
        exclude = ('hits',)

def isint(obj):
    return isinstance(obj, int)

loglevel_choices = [ (key, val) for key, val in logging._levelNames.items() if isint(key) ]

class LogMessageForm(forms.Form):
    log_level = forms.TypedChoiceField(choices=loglevel_choices, widget=forms.RadioSelect,
        coerce=int)
    message = forms.CharField(max_length=20)

